
public class IRCCommandCreator {

	private IRCClient client;
	
	public IRCCommandCreator(IRCClient client) {
		this.client = client;
	}
	
	public void nick(String nick){
		IRCCommand command = new IRCCommand();
		command.setCommand("NICK");
		command.addParameter(nick);
		client.send(command.getString());
	}
	
	public void user(String user, String mode, String firstName, String lastName){
		IRCCommand command = new IRCCommand();
		command.setCommand("USER");
		command.addParameter(user);
		command.addParameter(mode);
		command.addParameter("*");
		command.addParameter(firstName + lastName);
		client.send(command.getString());
	}
	
	public void join(String channel, String key) {
		IRCCommand command = new IRCCommand();
		command.setCommand("JOIN");
		command.addParameter(channel);
		if (key != null) {
			command.addParameter(key);
		}
		client.send(command.getString());
	}
	
	public void join(String channel) {
		join(channel, null);
	}
	
	public void part(String channel, String msg) {
		IRCCommand command = new IRCCommand();
		command.setCommand("PART");
		command.addParameter(channel);
		if (msg != null){
			command.addParameter(msg);
		}
		client.send(command.getString());
	}
	
	public void privmsg(String receiver, String msg) {
		IRCCommand command = new IRCCommand();
		command.setCommand("PRIVMSG");
		command.setNick(client.getNick());
		command.addParameter(receiver);
		command.addParameter(msg);
		client.evalCommand(command);
		client.send(command.getString());
	}
	
	public void quit(String msg) {
		IRCCommand command = new IRCCommand();
		command.setCommand("QUIT");
		if (msg != null){
			command.addParameter(msg);
		}
		client.send(command.getString());
	}
	
	public void quit() {
		quit(null);
	}
	
	public void topic(String channel, String topic) {
		IRCCommand command = new IRCCommand();
		command.setCommand("TOPIC");
		command.addParameter(channel);
		if (topic != null) {
			command.addParameter(topic);
		}
		client.send(command.getString());
	}
	
	public void topic(String channel) {
		topic(channel, null);
	}
	
	public void kick(String channel, String user, String msg) {
		IRCCommand command = new IRCCommand();
		command.setCommand("KICK");
		command.addParameter(channel);
		command.addParameter(user);
		if (msg != null) {
			command.addParameter(msg);
		}
		client.send(command.getString());
	}
	
	public void kick(String channel, String user) {
		kick(channel, user, null);
	}
	
	public void notice(String receiver, String msg) {
		IRCCommand command = new IRCCommand();
		command.setCommand("NOTICE");
		command.addParameter(receiver);
		command.addParameter(msg);
		client.send(command.getString());
	}
	
	public void whois(String user) {
		IRCCommand command = new IRCCommand();
		command.setCommand("NOTICE");
		command.addParameter(user);
		client.send(command.getString());
	}
	
	public void ping(String server){
		IRCCommand command = new IRCCommand();
		command.setCommand("PING");
		command.addParameter(server);
		client.send(command.getString());
	}
	
	public void pong(String server){
		IRCCommand command = new IRCCommand();
		command.setCommand("PONG");
		command.addParameter(server);
		client.send(command.getString());
	}
	
	public void away(String msg) {
		IRCCommand command = new IRCCommand();
		command.setCommand("AWAY");
		if (msg != null){
			command.addParameter(msg);
		}
		client.send(command.getString());
	}
	
	public void away() {
		away(null);
	}
	
}
